package com.sky.mapper.user;

import com.sky.pojo.ShoppingCart;
import com.sky.result.Result;
import org.apache.ibatis.annotations.*;

import java.util.List;

@Mapper
public interface ShoppingCartMapper {


    @Select("select * from shopping_cart where user_id = #{userId} and (setmeal_id = #{setmealId} or dish_id = #{dishId})")
    ShoppingCart getByDishIdOrSetmealId(Long setmealId, Long dishId, Long userId);

    @Update("update shopping_cart set number = #{num} where id = #{id}")
    void updateNumById(int num, Long id);

    @Insert("insert shopping_cart(name, user_id, dish_id, setmeal_id, dish_flavor, number, amount, image, create_time)" +
            "values (#{name},#{userId},#{dishId},#{setmealId},#{dishFlavor},#{number},#{amount},#{image},#{createTime}) ")
    void insert(ShoppingCart shoppingCart);

    @Select("select * from shopping_cart  where user_id = #{userId}")
    List<ShoppingCart> queryCart(Long userId);

    @Delete("delete from shopping_cart where user_id = #{userId}")
    void deleteShop(Long userId);


    Integer getMakeTimeByUserId(Long userId);
}
